﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SheZhiPanel : MonoBehaviour
{
    public Button YinYueButton, YinXiaoButton, ZhenDongButton;
    public AudioSource audio;
    void Start()
    {
        audio = GameObject.FindGameObjectWithTag("audio").GetComponent<AudioSource>();
        YinYueButton.onClick.AddListener(OnClickYinYueButton);
        YinXiaoButton.onClick.AddListener(OnClickYinXiaoButton);
        ZhenDongButton.onClick.AddListener(OnClickZhenDongButton);
        YinYueZhuangTai();
        YinXiaoZhuangTai();
        ZhenDongZhuangTai();


    }
    /// <summary>
    /// 音乐按钮
    /// </summary>
    public void OnClickYinYueButton()
    {
        if (audio.volume == 1)
        {
            audio.volume = 0;
            YinYueButton.image.color = new Color(1, 1, 1, 0.5f);
        }
        else
        {
            audio.volume = 1;
            YinYueButton.image.color = new Color(1, 1, 1, 1);
        }
    }
    /// <summary>
    /// 音效按钮
    /// </summary>
    public void OnClickYinXiaoButton()
    {
        if (ShortVoice.instance.IsPlay == false)
        {
            ShortVoice.instance.IsPlay = true;
            YinXiaoButton.image.color = new Color(1, 1, 1, 0.5f);
        }
        else
        {
            ShortVoice.instance.IsPlay = false;
            YinXiaoButton.image.color = new Color(1,1, 1, 1);
        }

    }
    public void OnClickZhenDongButton()
    {
        if (GoldAndLv.instance.IsZhenDong)
        {
            GoldAndLv.instance.IsZhenDong = false;
            ZhenDongButton.image.color = new Color(1, 1, 1, 1);

        }
        else
        {
            GoldAndLv.instance.IsZhenDong = true;
            ZhenDongButton.image.color = new Color(1, 1, 1, 0.5f);
        }
    }
    /// <summary>
    /// 音效状态
    /// </summary>
    public void YinXiaoZhuangTai()
    {
        if (ShortVoice.instance.IsPlay == false)
        {
            
            YinXiaoButton.image.color = new Color(1, 1, 1, 1);
        }
        else
        {
            
            YinXiaoButton.image.color = new Color(1, 1, 1, 0.5f);
        }
    }
    /// <summary>
    /// 音乐状态
    /// </summary>
    public void YinYueZhuangTai()
    {
        if (audio.volume == 1)
        {
            
            YinYueButton.image.color = new Color(1, 1, 1, 1);
        }
        else
        {
           
            YinYueButton.image.color = new Color(1, 1, 1, 0.5f);
        }
    }
    /// <summary>
    /// 震动显示
    /// </summary>
    public void ZhenDongZhuangTai()
    {
        if (GoldAndLv.instance.IsZhenDong)
        {
            ZhenDongButton.image.color = new Color(1, 1, 1, 0.5f);
        }
        else
        {
            ZhenDongButton.image.color = new Color(1, 1, 1, 1);
        }
    }
    




    }
